<template>
  <van-list
      v-model:loading="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
  >
    <Item v-for="(item,index) in list" :info="item" :key="index"></Item>
  </van-list>
</template>

<script setup>
import {defineProps, ref} from "vue";
import Item from "./components/Item/index.vue"
import  moment from "moment"
import {getOrderList} from "../../../../../api/index.js";
const props=defineProps(["status"])
const finished = ref(false);
const loading = ref(false);
const pageInfo= ref({
  page:1
})
const list = ref([])
const onLoad = async () => {
   const res= await getOrderList({
     status:props.status,
     page:pageInfo.value.page
   })
  console.log(res.data.data)
  const arr= res.data.data.map(ele=>({...ele,createtime:moment(ele.createtime*1000).format("YYYY-MM-DD")}))
  if(pageInfo.value.page==1){
      list.value=arr
  }else{
     list.value=[...list.value,...arr]
  }
  pageInfo.value.page++
  if(res.data.last_page<=res.data.current_page){
    finished.value = true;
  }


}
</script>

<style scoped>

</style>